﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using BCGC.BLL.BusinessObject.UserAccount;
using BCGC.DAL;

public partial class Controls_wucPostUser : System.Web.UI.UserControl
{
    private string _userAvater;
    public string UserAvater
    {
        get { return _userAvater; }
        set { _userAvater = value; }
    }

    private string _userName;
    public string UserName
    {
        get { return _userName; }
        set { _userName = value; }
    }

    private string _userID;
    public string UserID
    {
        get { return _userID; }
        set { _userID = value; }
    }

    private string _userMode;
    public string UserMode
    {
        get { return _userMode; }
        set { _userMode = value; }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        LoadData();
    }

    private bool _showTotalForumPosts;
    public bool ShowTotalForumPosts
    {
        get { return _showTotalForumPosts; }
        set { _showTotalForumPosts = value; }
    }

    private bool _showTotalMarketPosts;
    public bool ShowTotalMarketPosts
    {
        get { return _showTotalMarketPosts; }
        set { _showTotalMarketPosts = value; }
    }

    public void LoadData()
    {
        if (UserID != null)
        {
            UserInfo userInfo = UserInfo.GetUserInfoByUserID(Convert.ToInt32(UserID));
            if (userInfo != null)
            {
                thmImageOnline.ImageUrl = userInfo.OnlineOfflineImageUrl;
                thmImageOnline.ToolTip = (userInfo.IsOnline == true ? "Online" : "Offline");
                if (ShowTotalForumPosts != false)
                {
                    lblTotalPosts.Text = string.Format("{0:d}", userInfo.TotalPost);
                }

                if (ShowTotalMarketPosts != false)
                {
                    lblTotalPosts.Text = string.Format("{0:d}", userInfo.TotalMarketPost);
                }

                imgAvater.ImageUrl = userInfo.AvatarImageUrl;
                litUserName.Text = userInfo.Username;
                litUserMode.Text = userInfo.Mood;
            }

        }
    }
}
